package javaspaces;

import net.jini.space.JavaSpace;
import java.util.Random;

public class Consumer {

	private static Random r = new Random();

	public static void main(String args[]) {
		WorkEntry template = new WorkEntry();
		WorkEntry entry = template;
		JavaSpace space = Locator.getSpace();
		while (entry != null) {
			try {
				Thread.sleep(r.nextInt(100));
				entry = (WorkEntry) space.read(template, null, 10 * 1000);
				if (entry != null)
					System.out.println("CONSUMER: "+entry);
				else
					System.out.println("CONSUMER DONE");
			} catch (Exception e) {
				e.printStackTrace();
				System.out.println("-->>");
			}
		}

	}
}
